package cn.zhl.comparator;

import org.junit.Test;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-04-23 15:58
 **/
public class ComparatorTest {
	@Test
	public void test1() {
		List<String> list = Arrays.asList("lello", "my", "name", "ais", "Lilei");
		//根据字母升序排列
//        List<String> rs = list.stream().sorted(String::compareTo).collect(Collectors.toList());
//        Collections.sort(list,String::compareTo);
//        Collections.sort(list,(a,b)->a.length()-b.length());
//        Collections.sort(list, Comparator.comparingInt(String::length).reversed().thenComparing(String::compareTo));
//        list.sort(Comparator.comparingInt(String::length).reversed());
		list.sort(Comparator.comparingInt(String::length)
			.thenComparing(Comparator.comparing(String::toLowerCase)).reversed());
		System.out.println(list);
	}
}
